﻿using System;
using Gtk;
using Levi.Finance.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Utilities;

public partial class MainWindow: Gtk.Window
{	
	public ABC g;
	public MainWindow (ABC _g): base (Gtk.WindowType.Toplevel)
	{
		Build ();
		this.g = _g;
		bntSubmit.Clicked += new EventHandler(BtnSubmitClick);
	}
	
	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
	
	protected void BtnSubmitClick (object obj, EventArgs args){
		string username = this.username.Text.ToString();
		string password = this.password.Text.ToString();
		Package pack = new Package();
		pack.opt = 1;
		pack.username = username;
		pack.password = password;
		//string str = JsonConvert.SerializeObject(pack);
		//str = System.Text.Encoding.Default.g
		g.query.SendMessage(JsonConvert.SerializeObject(pack));
	}

	public void AlertMsg(string text){
		this.label3.Text = text;
	}
}
